<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{asset('/control/city_linkage/css/city-picker.css')}}"/>
    <link rel="stylesheet" href="{{asset('/css/web/user/pw_revise.css')}}">
</head>
<body>
@include('web.layout.header')
@include('web.layout.user_tab')
<div class="base_member_content">
    <div class="w1200">
        @include('web.layout.member_nav')
        <div class="nav_right flr">
            <div class="base_content">
                <div class="line_title">验证手机修改</div>
                <div class="revise_subnav">
                    <ul>
                        <li>验证身份</li>
                        <li class="cur">修改验证手机</li>
                        <li>完成</li>
                    </ul>
                </div>
                <div class="revise_content">
                    <div class="box">
                        <form action="{{URL('member/user/phone_reviseth')}}" method="post" onsubmit="return frm_data_check();" id="js-frm-pwrevise">
                            <ul>
                                <li>
                                    <span>新手机号：</span>
                                    <input name='phone' id='phone' type="text" class="se getborder" />
                                    <p class="jm_error"></p>
                                </li>
                                <li>
                                    <span>请填写手机校验码：</span>
                                    <input name='code' id='code' type="text" class="yzm getborder">
                                    <p class="jm_error"></p>
                                    <a id='send_code' href="javascript:;" class="getmess j-validate-code">获取短信校验码</a>
                                    <div class="flr" id="timer"></div>
                                </li>
                                <input type="hidden" name="_token" value="{{csrf_token()}}" />
                                <input type="hidden" name="type" value="update" />
                            </ul>
                            <input type="submit" class="jm_btn6 submit" value="下一步" />
                        </form>
                    </div>
                    <div class="j-err" style="margin-left:312px; margin-top: 32px; color: red; font-size: large;"></div>
                </div>
                <div class="tips">
                    <h3>为什么要进行身份验证？</h3>
                    <div class="p">1. 为保障您的账户信息安全，在变更账户中的重要信息时需要进行身份验证，感谢您的理解和支持。<br>2. 验证身份遇到问题？请拨打客服电话400-016-6889。</div>
                </div>
            </div>
        </div>
    </div>
</div>
@include('web.layout.footer')
</body>
<script>
    $(function () {
        $('.j-validate-code').click(function () {
            $('.jm_error').html('');
            var _url = AJAX_URL + '/user/registermessages';
            var phone = $("#phone").val();
            $.get(_url, {phone:phone}, function(res){
                if(res.code == '0'){
                    var mytime = myDate.getTime(); //获取当前时间戳
                    var endMytime = mytime+1000*60; //计算结束时间戳
                    var phone = $("#phone").val();
                    $.cookie("endMytime",endMytime,{expires:endMytime});
                    $.cookie("phone",phone);
                    maxtime = 59;
                    timer = setInterval(CountDown,1000);
                    $("#send_code").hide();
                    $("#timer").html('60秒后可再次发送').show();
                    $(".phone-tips").show();
                    maxtime_phone = 5;
                    timer_phone = setInterval(CountDown_phone,1000);
                    layer.alert(res.message, {
                        icon: 1
                    });
                } else {
                    layer.alert(res.message, {
                        icon: 0
                    });
                }
            }, 'json');
        })


        $('#js-frm-pwrevise').submit(function () {
            //ajax提交获取
            url = $(this).attr('action');

            $.ajax({
                url: url,
                type: 'POST',
                dataType: 'json',
                data: $(this).serializeArray(),
                success: function (data) {
                    if (data.code == 0) {
                        layer.msg('修改成功，请重新登陆');
                        setTimeout(function(){ window.location.href = AJAX_URL + '/user/logout'; },3000);
                    } else {
                        layer.alert(data.message, {
                            icon: 1
                        });
                    }
                    ;
                }
            })
            return false;
        })




    })







    function frm_data_check() {
        var _frm = $('#js-frm-pwrevise');
        var _phone = _frm.find('input[name="phone"]'), _code = _frm.find('input[name="code"]');
        if (_phone.val() == ''){
            _phone.parent().find('.jm_error').html('新的手机号 必须填写');
            return false;
        }
        if (_code.val() == '') {
            _code.parent().find('.jm_error').html('手机校验码 必须填写');
            return false;
        }
    }
</script>
</html>